# 划分比例
# 训练集：70%，80%，75%
# 测试集：30%，20%，25%

# 数据集划分API
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

if __name__ == '__main__':
    # 加载鸢尾花数据集
    iris = load_iris()
    # 数据可视化
    # 1.数据类型的转换，用DataFrame存储数据
    iris_data = pd.DataFrame(data=iris.data, columns=iris.feature_names)
    iris_data['target'] = iris.target

    x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.3, random_state=0)
    """
    :param x_train: 训练集的特征
    :param x_test: 测试集的特征
    :param y_train: 训练集的标签
    :param y_test: 测试集的标签
    :return:
    参数的含义：
    test_size: 测试集的比例
    random_state: 随机种子,用于控制随机数的生成,随机数用于数据集的划分
    """
    print("测试集的形状:")
    print("训练集的形状:",x_train.shape)
    print("测试集的形状:",x_test.shape)
    print("训练集的形状:",y_train.shape)
    print("测试集的形状:",y_test.shape)
    print(f"比例划分：{x_train.shape[0]/iris.data.shape[0]}")
